home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 12.4 KB | 342 lines |
- [Name]
- TrackMatrix v1.0 - Provides events for positioning tracks
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- This behavior offers the following 5 functions (Scroll down for a better
- description of this behavior):
-
- MoveTrackBy : This event uses 3 Input Global Variables:
- TrackIndex -- the index of the track to move
- MoveTrackX -- The amount in the x direction
- MoveTrackY -- The amount in the y direction
- MoveTrackTo : This event uses 3 Input Global Variables:
- TrackIndex -- the index of the track to move
- MoveTrackX -- The x location
- MoveTrackY -- The y location
- (relative to the track containing this behavior)
- TrackLocation : This event uses 1 Input Global Variable:
- TrackIndex -- the index of the track
-
- This event returns 2 Output Global Variables:
- MoveTrackX -- The x location
- MoveTrackY -- The y location
- (relative to the track containing this behavior)
- TrackStatus : This event returns 9 Output Global Variables:
- NumTracks -- The total number of tracks in the movie
- NumVisibleTracks -- The number of visible spatial tracks
- MovieTop -- The relative location of the top of the movie
- MovieBottom -- The relative location of the bottom of the movie
- MovieLeft -- The relative location of the left of the movie
- MovieRight -- The relative location of the right of the movie.
- i.e. Width of movie = MovieLeft - MovieRight
- MovieFront -- Layer of the top-most track
- MovieBack -- Layer of the bottom-most track
- ReferenceIndex -- Index of sprite track containing this behavior
-
- IsTrackVisible : This event uses 1 Input Global Variable:
- TrackIndex -- the index of the track
-
- This event returns 1 Output Global Variables:
- TrackVisible -- 1 means it exists and is visible
- 0 means it exists and is not visible
- -1 means it does NOT exist
- NOTE: visible means it has positive dimensions and is enabled
- Non-spatial tracks are not be visible.
-
- Currently Quicktime is very limited in its ability to move tracks
- around, or to even know where they are. Briefly here are the
- limitations:
- 1) There is only a movematrixBy, no movematrixTo
- 2) movematrixBy only takes constants, no variables
- 3) movematrixBy doesn't work with negative numbers
- 4) there are no propertes to find the position of a track
- 5) There are no propertis to know how many tracks there are
- 6) There are no propertis to know the size of the movie.
- 7) No properties to get the index of the current track.
-
- This behavior gets around these limitations though matrix rotation
- and other tricks.
- See Demo Project for examples. Briefly, to use these functions, you
- should place this behavior in a sprite on a sprite track that you are
- going to use as your reference track. You shouldn't use these functions
- to move your reference track. To move other tracks, set the global
- variable, TrackIndex to the index of the track you want to move,
- then set the MoveTrackX and MoveTrackY global variables. Finally,
- execute the appropriate event, either MoveTrackBy or MoveTrackTo.
- For Example, if the behavior is in spriteofid(1), you can move the second
- track by (-5, 12) by saying:
-
- TrackIndex = 2
- MoveTrackX = -5
- MoveTrackY = 12
- spriteofid(1).executeevent($MoveTrackBy)
-
- Revision History:
-
-
- [Parameters]
-
- [200030 MoveTrackBy]
- GlobalVars TrackIndex MoveTrackX MoveTrackY MP_enabledstatus
- //Remember if the track started out enabled so we can restore it later
- MP_enabledstatus = TrackOfIndex(TrackIndex).TrackEnabled
- IF(MP_enabledstatus)
- //It is faster to move tracks that aren't enabled
- TrackOfIndex(TrackIndex).SetEnabled(FALSE)
- ENDIF
- //Do we need to move in the X direction?
- IF(MoveTrackX ≠ 0)
- ExecuteEvent(200031)
- ENDIF
- //Do we need to move in the Y direction?
- IF(MoveTrackY ≠ 0)
- ExecuteEvent(200032)
- ENDIF
- //Restore enabled Status
- IF(MP_enabledstatus)
- TrackOfIndex(TrackIndex).SetEnabled(TRUE)
- ENDIF
-
- [200031 MP_MoveTrackByX]
- GlobalVars MoveTrackX TrackIndex
- // first move in the negative direction by big amounts if needed
- // Moving tracks in the negative direction requires rotating the
- // The track twice.
- IF(MoveTrackX < 0)
- IF(MoveTrackX > -10)
- MoveTrackX = MoveTrackX + 10
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,5,0)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ELSEIF(MoveTrackX > -100)
- MoveTrackX = MoveTrackX + 100
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,50,0)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ELSEIF(MoveTrackX > -500)
- MoveTrackX = MoveTrackX + 500
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,250,0)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ELSE
- MoveTrackX = MoveTrackX + 2000
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,1000,0)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ENDIF
- ENDIF
- //Now Fine tune the position by moving in the positive direction
- //The reason why we need to do these loops is that MoveMatrixBy
- //only accepts constants, so we have to loop through preset values.
- WHILE (MoveTrackX >= 500)
- MoveTrackX = MoveTrackX - 500
- TrackOfIndex(TrackIndex).MoveMatrixBy(500,0)
- ENDWHILE
- WHILE (MoveTrackX >= 100)
- MoveTrackX = MoveTrackX - 100
- TrackOfIndex(TrackIndex).MoveMatrixBy(100,0)
- ENDWHILE
- WHILE (MoveTrackX >= 25)
- MoveTrackX = MoveTrackX - 25
- TrackOfIndex(TrackIndex).MoveMatrixBy(25,0)
- ENDWHILE
- WHILE (MoveTrackX >= 10)
- MoveTrackX = MoveTrackX - 10
- TrackOfIndex(TrackIndex).MoveMatrixBy(10,0)
- ENDWHILE
- WHILE (MoveTrackX >= 5)
- MoveTrackX = MoveTrackX - 5
- TrackOfIndex(TrackIndex).MoveMatrixBy(5,0)
- ENDWHILE
- WHILE (MoveTrackX >= 2)
- MoveTrackX = MoveTrackX - 2
- TrackOfIndex(TrackIndex).MoveMatrixBy(2,0)
- ENDWHILE
- WHILE (MoveTrackX >= 1)
- MoveTrackX = MoveTrackX -1
- TrackOfIndex(TrackIndex).MoveMatrixBy(1,0)
- ENDWHILE
-
-
- [200032 MP_MoveTrackByY]
- GlobalVars MoveTrackY TrackIndex
- //This is the same function as MoveTrackByX but in the Y direction
- IF(MoveTrackY < 0)
- IF(MoveTrackY > -10)
- MoveTrackY = MoveTrackY + 10
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,5)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ELSEIF(MoveTrackY > -100)
- MoveTrackY = MoveTrackY + 100
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,50)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ELSEIF(MoveTrackY > -500)
- MoveTrackY = MoveTrackY + 500
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,250)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ELSE
- MoveTrackY = MoveTrackY + 2000
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,1000)
- TrackOfIndex(TrackIndex).RotateMatrixBy(180,0,0)
- ENDIF
- ENDIF
- WHILE (MoveTrackY >= 500)
- MoveTrackY = MoveTrackY - 500
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,500)
- ENDWHILE
- WHILE (MoveTrackY >= 100)
- MoveTrackY = MoveTrackY - 100
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,100)
- ENDWHILE
- WHILE (MoveTrackY >= 25)
- MoveTrackY = MoveTrackY - 25
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,25)
- ENDWHILE
- WHILE (MoveTrackY >= 10)
- MoveTrackY = MoveTrackY - 10
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,10)
- ENDWHILE
- WHILE (MoveTrackY >= 5)
- MoveTrackY = MoveTrackY - 5
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,5)
- ENDWHILE
- WHILE (MoveTrackY >= 2)
- MoveTrackY = MoveTrackY - 2
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,2)
- ENDWHILE
- WHILE (MoveTrackY >= 1)
- MoveTrackY = MoveTrackY -1
- TrackOfIndex(TrackIndex).MoveMatrixBy(0,1)
- ENDWHILE
-
-
- [200033 MoveTrackTo]
- GlobalVars MP_mx MP_my MP_mx1 MP_my1 MoveTrackX MoveTrackY TrackIndex
- //There is no MoveMatrixTo, so we need to invent one. First we find the location
- //of the track. LiveStage doesn't give us a function for this, but we can determine
- //where the track thinks the mouse is, and then compare that to the location the reference
- //track thinks the mouse is. This will give us the locaiton of the track.
- //Then we do a MP_trackmoveby by the difference in the final location and the
- //current location.
- MP_mx = MouseHorizontal
- MP_mx1 = TrackOfIndex(TrackIndex).MouseHorizontal
- MP_my = MouseVertical
- MP_my1 = TrackOfIndex(TrackIndex).MouseVertical
-
- MP_mx = MoveTrackX - (MP_mx - MP_mx1)
- MP_my = MoveTrackY - (MP_my - MP_my1)
- MP_mx1 = MoveTrackX
- MP_my1 = MoveTrackY
- MoveTrackX = MP_mx
- MoveTrackY = MP_my
- //Now that we know how much to move by, perform the moveby event:
- SpriteOfID($thisSpriteID).ExecuteEvent(100030)
-
- [200034 TrackLocation]
- GlobalVars MP_mx MP_my MP_mx1 MP_my1 MoveTrackX MoveTrackY TrackIndex
- //LiveStage doesn't give us a function for track location, but we can determine
- //where the track thinks the mouse is, and then compare that to the location the reference
- //track thinks the mouse is. This will give us the locaiton of the track.
- MP_mx = MouseHorizontal
- MP_mx1 = TrackOfIndex(TrackIndex).MouseHorizontal
- MP_my = MouseVertical
- MP_my1 = TrackOfIndex(TrackIndex).MouseVertical
-
- MoveTrackX = (MP_mx - MP_mx1)
- MoveTrackY = (MP_my - MP_my1)
-
-
- [200035 TrackStatus]
- GlobalVars NumTracks NumVisibleTracks MovieTop MovieBottom MovieLeft MovieRight MovieFront MovieBack ReferenceIndex MP_mx MP_my MP_mx1 MP_my1
- LocalVars MP_tempvalue MP_TempLayer MP_GotIndex
- //Call this event to update movie and track parameters.
- //Initialize the variables:
- MP_tempvalue = 0
- MP_GotIndex = FALSE
- NumVisibleTracks = 0
- NumTracks = 1
- MovieTop = 0
- MovieBottom=0
- MovieLeft=0
- MovieRight=0
- MovieFront = TrackLayer
- MovieFront = TrackLayer
- WHILE(MP_tempvalue ≠ 314)
- //first set tempvalue to something, because if the track doesn't exist, the value won't be
- //updated.
- MP_tempvalue = 314
- MP_tempvalue = TrackOfIndex(NumTracks).TrackEnabled
- IF(MP_tempvalue ≠ 314)//track exists.
- IF(MP_tempvalue AND TrackOfIndex(NumTracks).TrackWidth AND TrackOfIndex(NumTracks).TrackHeight)
- //Find the location of the track
- NumVisibleTracks = NumVisibleTracks + 1
- MP_mx = MouseHorizontal
- MP_mx1 = TrackOfIndex(NumTracks).MouseHorizontal
- MP_my = MouseVertical
- MP_my1 = TrackOfIndex(NumTracks).MouseVertical
- MP_mx = MP_mx - MP_mx1 //x location of the track
- MP_my = MP_my - MP_my1 //y location of track
- //See if this is our this track's index or not:
- IF(NOT MP_GotIndex)
- // First see if the dimensions match
- IF(NOT MP_mx AND NOT MP_my AND (TrackOfIndex(NumTracks).TrackHeight = TrackHeight))
- //Now, to make sure, move the layer of one track and see if the other also moves
- MP_TempLayer = TrackOfIndex(NumTracks).TrackLayer
- TrackOfIndex(NumTracks).SetLayerTo(MP_TempLayer + 5)
- IF(TrackLayer = MP_TempLayer + 5)
- ReferenceIndex = NumTracks //This is our track!
- MP_GotIndex = TRUE
- ENDIF
- TrackOfIndex(NumTracks).SetLayerTo(MP_TempLayer) //Now restore the layer.
- ENDIF
- ENDIF
- //Find the maximum dimensions
- IF(MovieLeft > MP_mx)
- MovieLeft = MP_mx
- ENDIF
- IF(MovieRight < MP_mx + TrackOfIndex(NumTracks).TrackWidth)
- MovieRight = MP_mx+ TrackOfIndex(NumTracks).TrackWidth
- ENDIF
- IF(MovieTop > MP_my)
- MovieTop = MP_my
- ENDIF
- IF(MovieBottom < MP_my + TrackOfIndex(NumTracks).TrackHeight)
- MovieBottom = MP_my+ TrackOfIndex(NumTracks).TrackHeight
- ENDIF
- //Find Frontmost and backmost layers
- IF(MovieFront > TrackOfIndex(NumTracks).TrackLayer)
- MovieFront = TrackOfIndex(NumTracks).TrackLayer
- ELSEIF(MovieBack < TrackOfIndex(NumTracks).TrackLayer)
- MovieBack = TrackOfIndex(NumTracks).TrackLayer
- ENDIF
-
- ENDIF
- NumTracks = NumTracks + 1
- ELSE
- NumTracks = NumTracks - 1 //went too far. go back one.
- ENDIF
- ENDWHILE
-
- [200036 IsTrackVisible]
- GlobalVars TrackVisible TrackIndex
- LocalVars MP_tempvalue
- //Checks whether or not track of index TrackIndex exists and is visible
- //Returns results in Global Variable TrackVisible.
- // -1 means it doesn't exist. 1 means exists and is visible, 0 means exists but not visible
- MP_tempvalue = 314
- MP_tempvalue = TrackOfIndex(TrackIndex).TrackEnabled
- IF(MP_tempvalue ≠ 314)//track exists.
- IF(MP_tempvalue AND TrackOfIndex(TrackIndex).TrackWidth AND TrackOfIndex(TrackIndex).TrackHeight)
- TrackVisible = TRUE //track is visible
- ELSE
- TrackVisible = 0 //Track is not visible
- ENDIF
- ELSE
- TrackVisible = -1 //Track doesn't exist
- ENDIF
-
-
-
-
-
-
-
-